package com.et.dao.impl;
import java.util.HashMap;
import java.util.Map;

import unis.base.db.impl.GenericDaoImpl;
import unis.base.util.ValidateUtil;

import com.et.dao.CustomerInfoDao;
import com.et.dao.searchObj.CustomerInfoSearch;
import com.et.pojo.CustomerInfo;


public class CustomerInfoDaoImpl extends GenericDaoImpl<CustomerInfo,Integer> implements CustomerInfoDao {
	public CustomerInfoDaoImpl(Class<CustomerInfo> type) {
		super(type);
	}

	public CustomerInfo getCustomer(CustomerInfoSearch customerInfoSearch) {
		String hql = "FROM CustomerInfo WHERE 1=1";
		Map<String,Object> params=new HashMap<String, Object>();
		if(ValidateUtil.isNotNull(customerInfoSearch)){
			if(ValidateUtil.isNotEmpty(customerInfoSearch.email)){
				hql += " and email = :email";
				params.put("email", customerInfoSearch.email);
			}
			if(ValidateUtil.isNotEmpty(customerInfoSearch.customCode)){
				hql += " and customerCode = :customerCode";
				params.put("customerCode", customerInfoSearch.customCode);
			}
		}
		CustomerInfo customerInfo=(CustomerInfo)getUniqueResult(hql, params);
		return customerInfo;
	}
	
}
